package ink.openmind.threadexception;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @author wangzhuangzhuang
 * @Description:
 * @date 2022-05-18 13:07
 */
public class ThreadExceptionDemoWithFutureException {
	public static void main(String[] args) {
		ExecutorService threadPool = Executors.newFixedThreadPool(5);
		threadPool.submit(() -> {
			for(int i = 0; i < 5; i ++){
				Future<?> future = threadPool.submit(() -> {
					System.out.println("current thread name " + Thread.currentThread().getName());
					Object obj = null;
					System.out.println("result##" + obj.toString());
				});
				try{
					future.get();
				}catch (Exception e){
					System.out.println("发生异常");
				}
			}
		});
	}
}
//		current thread name pool-1-thread-2
//		发生异常
//		current thread name pool-1-thread-3
//		发生异常
//		current thread name pool-1-thread-4
//		发生异常
//		current thread name pool-1-thread-5
//		发生异常
//		current thread name pool-1-thread-2
//		发生异常